package com.dudu.dataImport;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * 数据库连接工具
 * 
 * @author weidong
 * 
 */
public class DBConnectionUtil {
	private String DRIVER = "com.mysql.jdbc.Driver";
	//正式环境
	//private String URL = "jdbc:mysql://223.202.3.198:3306/voip_plat_version3?useUnicode=true&amp;characterEncoding=UTF-8";
	//测试环境
	private String URL = "jdbc:mysql://223.202.31.209:3306/voip_plat_version3_bak20160317?useUnicode=true&amp;characterEncoding=UTF-8";//测试环境数据
	private String USER = "root";
	private String PASSWORD = "heguoping123@2014";

	/**
	 * 获取数据可连接
	 * 
	 * @return
	 */
	public Connection getDBConnection() {
		Connection conn = null;
		try {
			Class.forName(this.DRIVER).newInstance();
			conn = DriverManager.getConnection(this.URL, this.USER, this.PASSWORD);
			conn.setAutoCommit(false);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return conn;
	}
	public Connection getDBConnection(String url,String user,String pass) {
		Connection conn = null;
		try {
			Class.forName(this.DRIVER).newInstance();
			conn = DriverManager.getConnection(url, user, pass);
			conn.setAutoCommit(false);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return conn;
	}
}
